<?php


namespace util;

use Firebase\JWT\JWT;
use Firebase\JWT\Key;

class JwtUtils
{

    private static  $key="zaozaokeji2019@";

    public static function getUserToken($userid){
        $arr["userId"]=$userid;
        $jwt = JWT::encode($arr, self::$key, 'HS256');
        return $jwt;
    }
    public static function  getUserId($token){
        $res=JWT::decode($token, new Key(self::$key, 'HS256'));

        return $res->userId;
    }

    public static function getToken($arr){
        $jwt = JWT::encode($arr, self::$key, 'HS256');
        return $jwt;
    }
    public static function getDecodeToken($token){
        $res=JWT::decode($token, new Key(self::$key, 'HS256'));
        $res=json_decode(json_encode($res),true);
        return $res;
    }
}